package com.ljq.apipassenger.controller;
import com.ljq.intemalcommon.request.VerificationCodeDTO;
import com.ljq.apipassenger.service.VerificationCodeService;
import com.ljq.intemalcommon.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/verificationcode")
public class VerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService;

    /**
     * 获取手机号
     * @param Verification
     * @return
     */
    @PostMapping
    public ResponseResult verificationCode(@RequestBody VerificationCodeDTO Verification){
        String phone = Verification.getPhone();
        return verificationCodeService.VerificationCode(phone);
    }

    /**
     * 验证手机号和验证码
     * @param verificationCodeDTO
     * @return
     */
    @PostMapping("/verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPhone();
        String verificationCode = verificationCodeDTO.getCode();
        return verificationCodeService.checkVerificationCode(passengerPhone,verificationCode);
    }
}
